package com.hs.controller;

import com.alibaba.fastjson.JSONObject;
import com.hs.entity.User;
import com.hs.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author lxz
 * @Name
 * @Date 2024/11/14 10:03
 */
@RestController
@RequestMapping("/test")
public class TestController extends BaseController {

    @Autowired
    private IUserService userService;
    @GetMapping("1")
    public Object test(){
        return "1";
    }

    @GetMapping("2")
    public Object test1(){
        User user = new User();
        user.setGuid("10002");
        user.setName("张三");
        user.setPassword("123456");
        userService.save(user);
        return "1";
    }

    @GetMapping("3")
    public Object get(){

        User byId = userService.getById("10001");
        return JSONObject.toJSON(byId);
    }
}
